package com.admin.business.personalCenter.venusSysZhuyeappBank;

import com.tiangong.framework.annotation.OpenApi;
import com.tiangong.framework.bo.CDO;
import com.tiangong.framework.bo.Return;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 助业app银行卡提现信息表
 * @create: 2023-11-23 14:59:29
 **/
@Service("venusSysZhuyeappBankService")
@Slf4j
public class VenusSysZhuyeappBankService{

    @Resource
    VenusSysZhuyeappBankDao venusSysZhuyeappBankDao;

    /**
     * 添加助业app银行卡提现信息表,获取id数据
     *
     * @param cdoRequest - id:主键
     *                   - user_id:用户id
     *                   - bank_type:1.助业网 2.员工端 3.业主端(暂无)
     *                   - bank_no:银行卡号
     *                   - bank_code:开户行
     *                   - bank_code_id:开户行id
     *                   - bank_name:收款方用户名
     *                   - beginTime:创建时间
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return addVenusSysZhuyeappBank(CDO cdoRequest) {
        venusSysZhuyeappBankDao.addVenusSysZhuyeappBank(cdoRequest);
        CDO cdoResult = new CDO();
        if (cdoRequest.containsKey("id")) {
            cdoResult.set("id", cdoRequest.get("id"));
        }
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据id，更新助业app银行卡提现信息表数据
     *
     * @param cdoRequest - id:主键
     *                   - user_id:用户id
     *                   - bank_type:1.助业网 2.员工端 3.业主端(暂无)
     *                   - bank_no:银行卡号
     *                   - bank_code:开户行
     *                   - bank_code_id:开户行id
     *                   - bank_name:收款方用户名
     *                   - beginTime:创建时间
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return updateVenusSysZhuyeappBankById(CDO cdoRequest) {
        venusSysZhuyeappBankDao.updateVenusSysZhuyeappBankById(cdoRequest);
        return Return.SUCCESS;
    }

    /**
     * 根据id，删除助业app银行卡提现信息表数据
     *
     * @param cdoRequest - id:主键
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return deleteVenusSysZhuyeappBankById(CDO cdoRequest){
        int count = venusSysZhuyeappBankDao.deleteVenusSysZhuyeappBankById(cdoRequest.getLong("id"));
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据条件，删除助业app银行卡提现信息表数据
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return deleteVenusSysZhuyeappBank(CDO cdoRequest) {
        int count = venusSysZhuyeappBankDao.deleteVenusSysZhuyeappBank(cdoRequest);
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据ID，获取助业app银行卡提现信息表数据
     *
     * @param cdoRequest - id:主键
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return getVenusSysZhuyeappBankById(CDO cdoRequest) {
        CDO cdoMapperResult = venusSysZhuyeappBankDao.getVenusSysZhuyeappBankById(cdoRequest.getLong("id"));
        return Return.valueOf(cdoMapperResult);
    }

    /**
     * 根据非空条件，获取助业app银行卡提现信息表数据列表
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return getVenusSysZhuyeappBankListPage(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusSysZhuyeappBankDao.getVenusSysZhuyeappBankListPage(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusSysZhuyeappBankDao.getVenusSysZhuyeappBankCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
    /**
     * 根据混合条件，获取助业app银行卡提现信息表数据列表
     *
     * @param cdoRequest - id:主键
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return getVenusSysZhuyeappBankListPageByCondition(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusSysZhuyeappBankDao.getVenusSysZhuyeappBankListPageByCondition(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusSysZhuyeappBankDao.getVenusSysZhuyeappBankCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
}
